<template>
    <dict-select v-bind="$attrs" :dict />
</template>

<script setup>
import opt from '../ProjectOption'
import { reactive } from 'vue'

const props = defineProps({
    emptyAsCurrent: {
        type: Boolean,
        default: false,
    }
});

const yearSelect = [];
let init = props.emptyAsCurrent ? opt.ApplyYear - 1 : opt.ApplyYear;
for (let i = init; i >= 2014; i--) {
    yearSelect.push({
        DataKey: i.toString(),
        DataValue: i.toString(),
    });
}

const dict = reactive({
    name: "年度",
    entries: [
        {
            DataKey: props.emptyAsCurrent ? opt.ApplyYear.toString() : "",
            DataValue: `${props.emptyAsCurrent ? `当前年度（${opt.ApplyYear}）` : "请选择年度"}`,
        },
        ... yearSelect
    ]
});
</script>